<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
  <head>
    <?php include_http_metas() ?>
    <?php include_title() ?>
  </head>
  <body>
    <script type="text/javascript">
(function () {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:'   == document.location.protocol ? 'https://ssl'   : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
    </script>
<?php echo google_analytics_tag() ?>

<?php /*
We use an external redirect_uri wich then redirects to apps.facebook.com/<canvas_name>/install
because then Facebook displays a "Don't Allow" button instead of "Leave App".
*/
$url = 'https://www.facebook.com/dialog/oauth?client_id='.App::getCurrentApiId().'&redirect_uri='.urlencode(url_for('@install_step0', true)).'&scope=email,manage_pages';
?>
    <script type="text/javascript">
function redirect()
{
top.location.href='<?php echo $url ?>';
}

_gaq.push(redirect());

<?php /*
If for any reason we don't receive any response from analytics for 5 seconds,
we force the redirect.
*/ ?>
setTimeout(function(){redirect();},5000);

    </script>

    <?php echo link_to('Redirection...', $url, array( 'target' => '_top')) ?>

  </body>
</html>

